Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first possible annotation syntax #24

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Add first possible annotation syntax #24

wants to merge 11 commits into from

Conversation

ucyo
Copy link
Contributor

@ucyo ucyo commented Nov 29, 2022

fixes #17

@ucyo
Copy link
Contributor Author

ucyo commented Nov 29, 2022

Annotations are a bit difficult. The problem is the cleanup process. The cleanup process is being executed before any annotation script is run. This leads to problems if the cleanup process actually removes files from hard disk, which actually need to be around for the annotation process e.g. filesize checks for generated files. There are two options to solve the problem.

Problem

Let the annotation be the following

[run.dd.annotations]
filesize = "ls -al {output} | awk '{{print $5}}'"
modified = "ls -al /tmp/Cargo.toml.dd | awk '{{print $6\" \"$7\" \"$8}}'"

which returns the file size and the last modification date of the file. The filesize can not be computed afterwards, since {output} refers to a parameter from hyperfine.

Solutions

  • Execute the cleanup process externally
    This is not possible if the annotation command refers to parameters delivered by hyperfine
  • Attach annotation process with the cleanup (i.e. &&)
    Integration to cleanup can be done attaching the commands. But a cli tool for manipulation of json files is necessary e.g. for filesize
     jq --arg filesize $(ls -al /tmp/Cargo.toml.dd | awk '{{print $5}}') '.results[0].filesize=$filesize' out.json  > cat out.json

- In case there is a cleanup process already setup, then the annotation
  tasks will be prepended. Otherwise a cleanup process will be added and
  all annotations will be executed
/// Generate jq command to manipulate `hyperfine` result json
pub fn generate_jq_cmd(key: &str, cmd: &str, json: &str) -> String {
format!(
"jq --arg {0} $({1}) '.results[0].{0}=${0}' {2} > {2}",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This override of the file is not working with jq .. the output will be empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add possibility enhance json output from different commands
1 participant